package com.example.Administrator.shoujiweishi.fragments;

import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.Administrator.shoujiweishi.R;
import com.example.Administrator.shoujiweishi.activities.adapter.ShowAllAdapter;
import com.example.Administrator.shoujiweishi.fragments.base.BaseFragment;
import com.example.Administrator.shoujiweishi.utils.MyUtil;
import com.example.Administrator.shoujiweishi.vo.Contact;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/6/5 0005.
 */

public class ShowAllcontacts extends BaseFragment{
    private RecyclerView recyclerView;
    ShowAllAdapter myAdapter;
    static List<Contact> list;
    @Override
    public int getContentXML() {
        return R.layout.contactfragment;
    }

    @Override
    public void initData() {
        list= MyUtil.getAllContact();
        recyclerView= (RecyclerView) getthisview().findViewById(R.id.recycalconfra);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL));
        myAdapter = new ShowAllAdapter(list);
        recyclerView.setAdapter(myAdapter);

    }

    @Override
    public void initView() {

    }
    public static List<Contact> getcontactlist(String name){
        List<Contact> result=new ArrayList<Contact>();
        for (int i=0;i<list.size();i++){
            Contact c=list.get(i);
            if (c.getName().contains(name)||c.getPhonenum().contains(name)){
                result.add(c);
            }
        }

        return result;
    }
}
